home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / QD3D Juggler / Juggler Sources / C4BoxMaker.cp < prev    next >
Encoding:
Text File  |  1995-12-27  |  1.4 KB  |  64 lines  |  [TEXT/CWIE]

  1. //
  2. //    C4BoxMaker.cp
  3. //
  4. //    class C4BoxMaker
  5. //    Class for constructing a QD3D model consisting of 4 boxes
  6. //    with colored sides.
  7. //
  8. //    Based on the "Start Here" sample code from Apple.
  9. //
  10. //    by James Jennings
  11. //    Started November 22, 1995
  12. //
  13.  
  14. #include "C4BoxMaker.h"
  15. #include "StQ3Disposer.h"
  16.  
  17. #include "CBoxMaker.h"    // for making a single box
  18.  
  19. void
  20. C4BoxMaker::Make()
  21. {
  22.     CBoxMaker box;    // construct a colored box
  23.     TQ3Vector3D where;
  24.     TQ3ShaderObject    illuminationShader ;
  25.  
  26.     // Make a group to put it in
  27.     mObject = ::Q3DisplayGroup_New();
  28.     ThrowIfNil_(mObject);
  29.     
  30.     // Define a shading type for the group
  31.     // and add the shader to the group
  32.     illuminationShader = ::Q3PhongIllumination_New();
  33.     StQ3Disposer ill(illuminationShader);
  34.     ::Q3Group_AddObject(mObject, illuminationShader);
  35.     
  36.     // add the box four times
  37.     ::Q3Vector3D_Set(&where, 0, 0, 0);
  38.     AddObjectAt(box.Get(), &where);
  39.     
  40.     ::Q3Vector3D_Set(&where, 2, 0, 0);    
  41.     AddObjectAt(box.Get(), &where);
  42.     
  43.     ::Q3Vector3D_Set(&where, 0, 0, -2);    
  44.     AddObjectAt(box.Get(), &where);
  45.     
  46.     ::Q3Vector3D_Set(&where, -2, 0, 0);    
  47.     AddObjectAt(box.Get(), &where);
  48. }
  49.  
  50. void
  51. C4BoxMaker::AddObjectAt(TQ3Object theObject, TQ3Vector3D *where)
  52. {
  53.     TQ3TransformObject    transform;
  54.     TQ3GroupPosition    pos;
  55.     
  56.     transform = ::Q3TranslateTransform_New(where);
  57.     ThrowIfNil_(transform);
  58.     StQ3Disposer trn(transform);
  59.     pos = ::Q3Group_AddObject(mObject, transform);
  60.     ThrowIf_(pos==0);
  61.     pos = ::Q3Group_AddObject(mObject, theObject);    
  62.     ThrowIf_(pos==0);
  63. }
  64.